<?php

function gv($key, $default=false) {
// returns query GET value of specified $key, if available
    if (isset($_GET[$key]))
        return $_GET[$key];
    return $default;
}

function pv($key, $default=false) {
// returns HTTP POST value of specified $key, if available
    if (isset($_POST[$key]))
        return $_POST[$key];
    return $default;
}

function rv($key, $default=false) {
// returns REQUEST value of specified $key if available
    if (isset($_REQUEST[$key]))
        return $_REQUEST[$key];
    return $default;
}

function strip_array(&$arr) {
//recursively apply stripslashes() to an array
    foreach ($arr as $k => $v) {
        if (is_array($v)) {
            strip_array($arr[$k]);
        } else {
            $arr[$k] = stripslashes($v);
        }
    }
}

function mres_array(&$arr) {
//recursively apply mysql_real_escape_string() to an array
    foreach ($arr as $k => $v) {
        if (is_array($v)) {
            mres_array($arr[$k]);
        } else {
            $arr[$k] = mysql_real_escape_string($v);
        }
    }
}
